﻿using GameServer.Network;
using Proto;
using Summer;
using Summer.Network;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GameServer.Service
{
    public class ChatService:Singleton<ChatService>
    {
        public void Start()
        {
            MessageRouter.Instance.Subscribe<ChatRequest>(_ChatRequest);
        }

        private void _ChatRequest(Connection sender, ChatRequest msg)
        {
            var session = sender.Get<Session>();
            var chr = session.Character;
            var resp = new ChatResonse();
            resp.SenderId = chr.entityId;
            resp.TextValue = msg.TextValue;
            chr.Space.Broadcast(resp);
        }
    }
}
